import './company.less';
import { Link, history } from 'umi';
import { Button, Form, Input } from 'antd';
import { getAll } from '@/services/settings/company';
import { useEffect, useState } from 'react';

function setCompany() {
    const [data, setData] = useState([]);
    const getData = async () => {
        const { data, code } = await getAll();
        setData(data);
        
    };
    let search='';
    useEffect(() => {
        getData();
    }, [])
    // console.log(data);
    type FieldType = {
        search?: string;
        password?: string;
        remember?: string;
    };
    // 搜索按钮
    const onFinish = (values: any) => {
        search=values.search;
        getData()
        console.log('Success:', values);
    };
    const pathAdd = () => {
        history.push('/home/settings/set/setAdd');
    }
    return <div>
        <div className="formBox">
            <Form
                className='form'
                name="search"
                onFinish={onFinish}
            >
                <Form.Item<FieldType>
                    name="search"
                    rules={[{ required: true, message: '' }]}
                >
                    <Input placeholder="摘要/备注/票据号/往来单位" />
                </Form.Item>
                <Form.Item className='itemBtn'>
                    <Button className='btnSearch' htmlType="submit">
                        搜索
                    </Button>
                    <Button className='btnSearch' onClick={pathAdd}>
                        创建
                    </Button>
                </Form.Item>
            </Form>

        </div>
        <div className='gongSiBox'>
            {data.map((item: any) => (
                <Link style={{ color: 'black' }} to={`/home/settings/set/setEdit?${item.sobId}`} key={item.sobId}>
                    <div className='gongSi'>
                        <h3>{item.companyName}</h3>
                        <div className='content'>
                            <h4>公司测试账套</h4>
                            <div>启用时间：2022年3月</div>
                            <div>会计准则：小企业会计</div>
                        </div>
                    </div>
                </Link>
            ))}
        </div>
    </div>
};
export default setCompany;